package itsur.arquitecturas.implicitinvocation;

/**************************************************************************************
** Class name: SystemInitialize
** Author: A.J. Lattanze
** Date: 12/29/99
** Version 1.0
** Purpose: Assignment 3 for Se 17-655, Architectures for Software Systems. The purpose
** of this assignment is to introduce implicit invocation architectures.
**
** Abstract: This program is a contrived student registration system. It is a menu
** driven system that will allow the following options.
**
**	1) List Students
**	2) List Courses
**	3) List Courses a Student has Registered for
**	4) List Students Registered for a Course
**	5) Register a Student for a Course
**	X) Exit
**
** System functionality is partitioned into components that communicate through
** a virtual bus implimented by using Java the observer/observable classes.  State is
** maintained through common data implimented through the use of class variables.
**
** The purpose of this method is to initialize the system.  First each component is instantiated.
** Here is where the component name and an ID is assigned.  It would be nice if this was
** dynamic so that components could be added on the fly.  In the original version of this system,
** the components were standalone threads - but that was removed because the scope of the assignment
** started to get out of hand (too much to modify for the amount of time allowed to do
** the assignment).  Finally, the Executive component is started.
**
** Pseudo Code:
**
** Running the program:
**
** java SystemInitialize
**
** The default input files: Courses.txt and Students.txt are used.
**	An example course data file has been provided: Courses.txt
**	An example student data file has been provided: Students.txt
**
***************************************************************************************
** Modification Log
**************************************************************************************
** Modification by: A.J. Lattanze
** Date: 01/24/02
** Version 1.5
** Description: The system has been changed to run as a multi-threaded event model.
** Each component:
**
**		RegisterStudentComponent.run();
**		ListStudentsComponent.run();
**		ListCoursesComponent.run();
**		ListCoursesRegisteredComponent.run();
**		ListStudentRegisteredComponent.run();
**
** ...runs as a stand-alone thread.
***************************************************************************************
** Modification by: ITSUR
** Date: 02/12/08
** Version 1.6
** Description: This class has been changed to add a 3 new components:
**   -ListPendingCORECoursesComponent
**   -ListCoursesTakenComponent
**   -RegisterStudentIntelliSectionComponent
**************************************************************************************/

public class SystemInitialize
{
   public static void main ( String argv[] )
   {
		// We instantiate each system component.
		// After these components are instantiated, they simply wait until the
		// Executive broadcasts changes.  The broadcast message includes a
		// registration number.  These IDs are used in broadcasts to components.
		// The component name is also included and is used whenever a caller
		// wants to reference a component.  Rather than have to rememeber a
		// number, they can reference a component by name.  I used the declared
		// name of the object, but you could use anything you want.
		// *******************************************************************


		Thread	RegisterStudentComponent = new Thread((Runnable) new  RegisterStudent( new Integer(100), "RegisterStudentComponent" ));

		RegisterStudentComponent.setDaemon(false);

		Thread	ListStudentsComponent =
		new Thread((Runnable) new ListStudents(new Integer(101), "ListStudentsComponent" ));

		ListStudentsComponent.setDaemon(false);

		Thread ListCoursesComponent =
		new Thread((Runnable) new ListCourses(new Integer(102), "ListCoursesComponent" ));

		ListCoursesComponent.setDaemon(false);

		Thread ListCoursesRegisteredComponent =
		new Thread((Runnable) new ListCoursesRegistered(new Integer(103), "ListCoursesRegisteredComponent"));

		ListCoursesRegisteredComponent.setDaemon(false);

		Thread ListStudentsRegisteredComponent =
		new Thread((Runnable) new ListStudentsRegistered(new Integer(104), "ListStudentsRegisteredComponent"));

		ListStudentsRegisteredComponent.setDaemon(false);

		Thread ExecutiveComponent =
		new Thread((Runnable) new Executive(new Integer(105), "ExecutiveComponent"));

		ExecutiveComponent.setDaemon(false);

		//ITSUR components
		Thread ListPendingCORECoursesComponent =
			new Thread((Runnable) new ListPendingCORECourses(new Integer(106), "ListPendingCORECoursesComponent"));

		ListPendingCORECoursesComponent.setDaemon(false);
		

		
		Thread ListCoursesTakenComponent =
			new Thread((Runnable) new ListCoursesTaken(new Integer(107), "ListCoursesTakenComponent"));

		ListCoursesTakenComponent.setDaemon(false);
		
		Thread RegisterStudentIntelliSectionComponent =
			new Thread((Runnable) new RegisterStudentIntelliSection(new Integer(108), "RegisterStudentIntelliSectionComponent"));

		RegisterStudentIntelliSectionComponent.setDaemon(false);		
		
		
		// Start the system up

		RegisterStudentComponent.start();
		ListStudentsComponent.start();
		ListCoursesComponent.start();
		ListCoursesRegisteredComponent.start();
		ListStudentsRegisteredComponent.start();
		ExecutiveComponent.start();

		//ITSUR component
		ListPendingCORECoursesComponent.start();
		RegisterStudentIntelliSectionComponent.start();
		ListCoursesTakenComponent.start() ;
		
   	} // main

} // class
